part of '../../repository.dart';

const _kPurchaseAppStoreTransactionOwnershipTypeValue = 'purchase';
const _kFamilySharingAppStoreTransactionOwnershipTypeValue = 'family_sharing';

class _AppStoreTransactionOwnershipTypeDto extends Equatable {
  const _AppStoreTransactionOwnershipTypeDto._internal({
    required this.ownershipTypeString,
  });

  final String ownershipTypeString;

  @override
  List<Object?> get props {
    return [
      ownershipTypeString,
    ];
  }

  factory _AppStoreTransactionOwnershipTypeDto.fromString(String ownershipTypeString) {
    return _AppStoreTransactionOwnershipTypeDto._internal(
      ownershipTypeString: ownershipTypeString,
    );
  }

  AppStoreTransactionOwnershipType toEntity() {
    return switch (ownershipTypeString) {
      _kPurchaseAppStoreTransactionOwnershipTypeValue => AppStoreTransactionOwnershipType.purchase,
      _kFamilySharingAppStoreTransactionOwnershipTypeValue =>
        AppStoreTransactionOwnershipType.familySharing,
      _ => throw UnimplementedError(),
    };
  }
}
